package game.johan.engine;

/*
Copyright (C) 2013 Johan Ceuppens

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.image.*;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.awt.*;
import javax.swing.*;

import java.awt.*;
import javax.swing.*;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.GraphicsEnvironment;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.Timer;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.GraphicsEnvironment;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.Timer;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.Timer;

class Tile<tid>
{

	/*
 	 * Creator of Tiles template subclass
	 */
	abstract class Creator<Return,Value>
	{
	private Value id;

	public Creator(Value v) {
		id = v;
	}

	public Value getid() { return id; }

	abstract Return create();
	};
	
	/*
 	 * TileCreator template subclass
	 */
	abstract class TileCreatorBase<Type,Return,Value> extends Creator<Return,Value>
	{
		TileCreatorBase(Value id) { super(id); }
		abstract Return create();//return new Type()
	};
	public class TileCreator extends TileCreatorBase<Object,Tile,Id>
	{
		TileCreator(Id id) { super(id); }
		public Tile create() { return new Tile<Id>(); }//FIXMENOTE return new Type()
	};


	/*
	 * Id class
	 */
	abstract class Id<tid>
	{	
	abstract tid getId();//FIXMENOTE TypeInfo class, getTypeName() (returns String) 
	public void init(tid c) { this.adaptTo(c); }
	abstract void adaptTo(tid c);
	abstract boolean matches(Id<tid> i);	
	};

	public Tile()	{}

	static TileDictionary _tilesdict = new TileDictionary();
}


